<template>
	<Layout class="p-5 bg-white">
		<Form :label-width="130" ref="warehouse" :model="warehouse">
			<FormItem class="w-50" label="请输入仓库名称">
				<Input v-model="warehouse.warehouseName"></Input>
			</FormItem>
			<FormItem class="w-50" label="请输入仓库地址" prop="password">
				<Input v-model="warehouse.address"></Input>
			</FormItem>

			<FormItem class="w-50" label="请输入仓库状态:">
				<Select placeholder="请选择" clearable v-model="warehouse.state">
					<Option v-for="p in statuList" :value="p.key">{{p.value}}</Option>
				</Select>
			</FormItem>

			<FormItem class="w-50" label="请输入管理员姓名:">
				<Select class="w-100" v-model="warehouse.userId" clearable placeholder="请选择管理员">
					<Option v-for=" item in allusername" :value="item.userId">{{item.userName}}</Option>
				</Select>
			</FormItem>

			<FormItem class="text-auto">
				<Button @click="submit" type="primary">保存</Button>
				<Button @click="cancel" class="ml-5">返回</Button>
			</FormItem>
		</Form>
	</Layout>
</template>

<script>
	export default {
		data() {
			return {
				warehouse: {
					warehouseId: "",
					warehouseName: "",
					address: "",
					state: "",
					userName: "",
					userId: "",
					storeId: 1
				},
				warehouses: [],
				allusername:[],
				statuList: [{
						key: 1,
						value: "启用"
					},
					{
						key: 0,
						value: "禁用"
					}
				],
			}
		},
		created: function() {
			this.getParent();
		},
		methods: {
			submit: function(warehouse) {
				let self = this;
				this.http.post({
					url: "/warehouse/info",    //新增接口地址
					param: {
						warehouseName: this.warehouse.warehouseName,
						address: this.warehouse.address,
						state: this.warehouse.state,
						userName: this.warehouse.userName,
						userId: this.warehouse.userId,
						storeId : this.warehouse.storeId
					}
				}).then(data => {
					self.message.info("添加成功");
					self.$tabs.close();
				});
			},
			cancel: function() {
				this.$tabs.close();
			},
			getParent:function(){
				this.http.get({
					url:"user/info/all",//获取管理员姓名
					param: {
						storeId: this.warehouse.storeId
					}
				}).then(data => {
					this.allusername = data.resultData
				});
			}
		}
	}
</script>

<style>
</style>
